import React from 'react';
import GroupHeader from '@/components/GroupHeader';

const Layout: React.FC<{ children: any; history: any }> = (props) => {
  var options = [
    { title: '课程统计', path: '/teaching/stat/course' },
    { title: '学生统计', path: '/teaching/stat/student' },
    { title: '考试统计', path: '/teaching/stat/exam' },
    { title: '实验统计', path: '/teaching/stat/exp' }
  ];
  var op = options.find((item) => item.path === props.history.location.pathname);
  if (!op) props.history.push(options[0].path);

  return (
    <>
      <GroupHeader
        onChage={(value) => {
          props.history.push(value.path);
        }}
        defaultValue={op ? op.title : options[0].title}
        prefix="学习统计"
        options={options}
      ></GroupHeader>
      {props.children}
    </>
  );
};

export default Layout;
